<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>layout 后台大布局 - Layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">

<style>
#keywords {
	float: left;
	min-width: 18%;
}
</style>
<link rel="stylesheet" href="css/layui.css" media="all">


</head>
<body class="layui-layout-body">
	<div class="layui-layout layui-layout-admin">
		<div class="layui-header">
			<div class="layui-logo">爱阅电子书城</div>
			<!-- 头部区域（可配合layui已有的水平导航） -->
			<ul class="layui-nav layui-layout-right">
				<li class="layui-nav-item"><a href="javascript:;"> <img
						src="http://t.cn/RCzsdCq" class="layui-nav-img"> <%=session.getAttribute("adminName")%>
				</a>
					<dl class="layui-nav-child">
						<dd>
							<a href="javascript:adminInfofun('${user.userName}')">基本资料</a>
						</dd>
						<dd>
							<a href="">安全设置</a>
						</dd>
					</dl></li>
				<li class="layui-nav-item"><a href="">退了</a></li>
			</ul>
		</div>

			<div class="layui-side layui-bg-black">
			<div class="layui-side-scroll">
				<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
				<ul class="layui-nav layui-layout-right" lay-filter="test">
					<li class="layui-nav-item "><a class="" >图书管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="addBookInfo.jsp">添加图书</a>
							</dd>
							<dd>
								<a href="bookInfo.jsp">图书信息</a>
							</dd>

						</dl></li>

					<li class="layui-nav-item"><a class="" >图书类型管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="addBookTypeInfo.jsp">添加图书类型</a>
							</dd>
							<dd>
								<a href="bookTypeInfo.jsp">图书类型信息</a>
							</dd>

						</dl></li>

					<li class="layui-nav-item"><a class="" >用户管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="addUsers.jsp">添加用户</a>
							</dd>
							<dd>
								<a href="userInfo.jsp">用户信息</a>
							</dd>

						</dl></li>
					<li class="layui-nav-item"><a class="" >订单管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="adminOrders.jsp">订单查询</a>
							</dd>

						</dl></li>
				</ul>
			</div>
		</div>

		<div class="layui-body">
			<!-- 内容主体区域 -->
			<div style="padding: 15px;">
				<fieldset class="layui-elem-field layui-field-title"
					style="margin-top: 30px;">
					<legend>用户信息查询</legend>
				</fieldset>
				<!-- 用户名关键字查询 -->
				<form class="navbar-form navbar-right" action="UserServlet"
					method="post">
					<div>
						<input type="text" class="layui-input" name="keywords"
							id="keywords" value="${keywords}" placeholder="关键字"
							style="width: 150px;">
						<button class="layui-btn layui-btn-normal" type="submit">查询</button>
						<input type="hidden" name="op" value="queryByPage">
					</div>

				</form>
				<span style="color: red"><%=request.getAttribute("msg") == null ? "" : request.getAttribute("msg")%></span>
				<table class="layui-table">
					<thead>
						<tr>
							<th>ID</th>
							<th>用户名</th>
							<th>密码</th>
							<th>身份证号</th>
							<th>电话</th>
							<th>地址</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<!-- 如果属性范围内的pd为null，我们就跳转到NewsTypeServlet去获取数据，然后再转发回来 -->
						<c:if test="${pd==null}">
							<!-- c:redirect 跳转到 NewsTypeServlet -->
							<c:redirect url="UserServlet?op=queryByPage"></c:redirect>
						</c:if>
						<!-- 如果 范围内的list不为空，遍历数据并展示结果 -->
						<c:if test="${pd!=null}">
							<c:forEach items="${pd.data}" var="user">
								<tr>
									<td>${user.userId}</td>
									<td>${user.userName}</td>
									<td>${user.userPwd}</td>
									<td>${user.idCard}</td>
									<td>${user.tel}</td>
									<td>${user.addr}</td>
									<td><a class="layui-btn layui-btn-xs" lay-event="edit"
										href="javascript:updatefun('${user.userName}')">编辑</a> <a
										class="layui-btn layui-btn-danger layui-btn-xs"
										lay-event="del" href="javascript:delfun('${user.userId}')">删除</a></td>
								</tr>
							</c:forEach>
						</c:if>
					</tbody>
				</table>

			</div>
			<!-- 显示 分页导航区域 -->
			<div id="pagediv" style="text-align: center"></div>
		</div>

		<div class="layui-footer">
			<!-- 底部固定区域 -->
			© layui.com - 底部固定区域
		</div>
	</div>
	<script src="js/jquery-2.0.3.js"></script>
	<script src="layui/layui.js" charset="utf-8"></script>
	<script src="layui/layui.all.js" charset="utf-8"></script>
	<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

	<script>
layui.use(['laypage', 'layer'], function(){
  var laypage = layui.laypage
  ,layer = layui.layer;
  
//完整功能
  laypage.render({
    elem: 'pagediv' // 分页的导航在哪里显示，pagediv是层id
    ,theme: '#428bca'  //颜色
    ,count: ${pd.totalCount} //总记录数
    ,curr: ${pd.page}  //当前页
    ,limit: ${pd.pageSize}//当前页显示的记录数
    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
    ,jump: function(obj, first){ //跳转页面时候的动作
	    //obj包含了当前分页的所有参数，比如：
	    // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
	   // console.log(obj.limit); //得到每页显示的条数
	    
	    //首次不执行
	    if(!first){
	      //do something
	       location.href="UserServlet?op=queryByPage&page="+obj.curr+"&pageSize="+obj.limit+"&keywords="+$("#keywords").val();
	    }
	  }
  });
});
</script>


	<!-- 删除用户 -->
	<script>
	<!--删除-->
		function delfun(userId) {
			var flag = confirm("请问确定删除编号为[" + userId + "]的用戶");

			if (flag) {
				location.href = "http://localhost:8080/love_reading_ebook_city/UserServlet?op=del&userId="
						+ userId;
			}

		}
		
		<!--修改前默认显示信息-->
		function updatefun(userName){
			location.href = "http://localhost:8080/love_reading_ebook_city/UserServlet?op=updateInfo&userName="
				+ userName;
			
		}
		
        <!--跳转到个人信息-->
	function adminInfofun(adminName){
		location.href = "http://localhost:8080/love_reading_ebook_city/AdminServlet?op=admininfo&adminName="
			+ adminName;
	} 
		
	</script>
</body>
</html>
